1. Field
Invention relates generally to rasterizers and, more particularly, to accelerating the conversion of primitives defined by vertexes to equivalent images composed of pixel patterns that can be stored and manipulated as sets of bits.
2. Related Art
Raster displays are commonly used in computer graphics systems. These displays store graphics images as a matrix of the smallest picture elements that can be displayed on a screen (“pixels”) with data representing each pixel being stored in a display buffer. This data specifies the display attributes for each pixel on the screen such as the intensity and color of the pixel. An entire image is read from the display buffer and displayed on the screen by sequentially scanning out horizontal rows of pixel data or “scan lines.”
Raster display systems commonly use polygons as basic building blocks or “primitives” for drawing more complex images. Triangles are a common basic primitive for polygon drawing systems, since a triangle is the simplest polygon and more complex polygons can be represented as sets of triangles. The process of drawing triangles and other geometric primitives on the screen is known as “rasterization.”
An important part of rasterization involves determining which pixels fall within a given triangle. Rasterization systems generally step from pixel to pixel in various ways and determine whether or not to “render,” i.e. to draw into a frame buffer or pixel map, each pixel as part of the triangle. This, in turn, determines how to set the data in the display buffer representing each pixel. Various traversal algorithms have been developed for moving from pixel to pixel in a way such that all pixels within the triangle are covered.
Rasterization systems sometimes represent a triangle as a set of three edge-functions. An edge function is a line equation representing a straight line, which serves to subdivide a two-dimensional plane. Edge functions classify each point within the plane as falling into one of three regions: the region “inside” of the triangle, the region “outside” of the triangle or the region representing the line itself. The type of edge function that will be discussed has the property that points “inside” of the triangle have a value greater than zero, points “outside” have a value less than zero, and points exactly on the line have a value of zero. This is shown in FIG. 1a. Applied to rasterization systems, the two-dimensional plane is represented by the graphics screen, points are represented by individual pixels, and the edge function serves to subdivide the graphics screen.
The union of three edges, or more particularly three half-planes, each of which is specified by edge functions, create triangles. It is possible to define more complex polygons by using Boolean combinations of more than three edges. Since the rasterization of triangles involves determining which pixels to render, a tiebreaker rule is generally applied to pixels that lie exactly on any of the edges to determine whether the pixels are to be considered interior or exterior to the triangle.
As shown in FIG. 1b, each pixel has associated with it a set of edge variables (e0, e1 and e2) which are proportional to the signed distance between the pixel and the three respective edges. The value of each edge variable is determined for a given triangle by evaluating the three edge functions, f0(x,y), f1(x,y) and f2(x,y) for the pixel location. It is important to note that it can be determined whether or not a pixel falls within a triangle by looking at only the signs of e0, e1 and e2.
In determining which pixels to render within a triangle, typical rasterization systems compute the values of the edge variables (e0, e1 and e2) for a given set of three edge functions and a given pixel position, and then use a set of increment values (Δeoutside, Δeinside, etc.) to determine the edge variable values for adjacent pixels. The rasterization system traverses the triangle, adding the increment values to the current values as a traversal algorithm steps from pixel to pixel.
With reference again to FIG. 1a, a line is illustrated that is defined by two points: (X,Y) and (X+dX, Y+dY). As noted above, this line can be used to divide the two dimensional space into three regions: all points “outside” of, “inside” of, and exactly on the line. The edge f(x,y) can be defined as f(x,y)=(x−X)dY−(y−Y)dX. This function has the useful property that its value is related to the position of the point (x,y) relative to the edge defined by the points (X,Y) and (X+dX, Y+dY):
f(x,y)>0 if (x,y) is “inside”;
f(x,y)=0 if (x,y) is exactly on the line; and
f(x,y)<0 if (x,y) is “outside”.
Existing rasterization systems commonly use this function, since it can be computed incrementally by simple addition: f(x+1,y)=f(x,y)+dY and f(x,y+1)=f(x,y)−dX.
A variety of different traversal algorithms are presently used by different rasterization systems in the rendering process. Any algorithm guaranteed to cover all of the pixels within the triangle can be used. For example, some solutions involve following the sides of the triangle while identifying a horizontal or vertical span of pixels therein. Following the sides of the triangle is adequate for the triangle edges, but if the triangle is clipped by a near or far plane, these boundaries are not known explicitly and cannot be followed as easily as the triangle edges. Other methods test individual pixels one at a time. In the recent past multiple pixels are tested in parallel to speed up the rasterization process.
Some conventional rasterizers use span-based pixel generation and contain edge and span interpolators based on the well-known Bresenham algorithm. The speed of those rasterizers depends on the interpolation speed. Furthermore, they require a complicated setup process. In most cases such rasterizers interpolate many associated parameters such as color, texture, etc. with appropriate hardware. Increasing the speed of such rasterizers requires a significant increase in the number and complexity of the interpolators, an approach not suitable for commercial products. In the case of clipping support, the structure of such rasterizers is too complex for efficient implementation.
Another approach is to use area rasterizers based on a definition of inner and outer pixels, grouped into blocks, with checking corner pixels' equation values to define inner, border and outer blocks. This approach may accelerate the generation of bit-masks of inner blocks, but the border blocks either need to be processed pixel by pixel or need a significant amount of dedicated hardware for processing those pixels in parallel.
Accordingly, there is a need for a low-cost high-speed rasterizer having a simple and uniform structure and capable of generating multiple spans per clock cycle.